VERSION 5.00
Begin VB.Form ReferClinicForm 
   BackColor       =   &H00FFFFFF&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   9000
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   12000
   LinkTopic       =   "Form1"
   ScaleHeight     =   9000
   ScaleWidth      =   12000
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   WindowState     =   2  'Maximized
   Begin VB.CommandButton Back_Button 
      Caption         =   "Back"
      BeginProperty Font 
         Name            =   "Arial Narrow"
         Size            =   20.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   9600
      TabIndex        =   5
      Top             =   7560
      Width           =   1935
   End
   Begin VB.CommandButton Counseling_Button 
      Caption         =   "Counseling"
      BeginProperty Font 
         Name            =   "Arial Narrow"
         Size            =   20.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   9600
      TabIndex        =   4
      Top             =   5520
      Width           =   1935
   End
   Begin VB.CommandButton Cancel_Button 
      BackColor       =   &H008080FF&
      Caption         =   "Cancel"
      BeginProperty Font 
         Name            =   "Arial Narrow"
         Size            =   20.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   9600
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   6540
      Width           =   1935
   End
   Begin VB.CommandButton FullVCT_Button 
      Caption         =   "Full VCT"
      BeginProperty Font 
         Name            =   "Arial Narrow"
         Size            =   20.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   9600
      TabIndex        =   0
      Top             =   4500
      Width           =   1935
   End
   Begin VCT.TouchScreenListBox LB 
      Height          =   4575
      Left            =   840
      TabIndex        =   2
      Top             =   4200
      Width           =   5055
      _ExtentX        =   8916
      _ExtentY        =   8070
   End
   Begin VCT.ClientSexHistCtrl SEXHX 
      Height          =   3855
      Left            =   300
      TabIndex        =   3
      Top             =   240
      Width           =   11415
      _ExtentX        =   20135
      _ExtentY        =   6800
   End
End
Attribute VB_Name = "ReferClinicForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'REFERRED - Referred to MACRO clinic today
'Back to STISYMPT

Private Sub Back_Button_Click()
   TBSYMPT = ""
   REFERRED = ""
   TBSymptomsForm.Show
   Unload Me
End Sub

Private Sub Cancel_Button_Click()
   VCTStageForm.Show
   Unload Me
End Sub

Private Sub Counseling_Button_Click()

   Dim tempstr As String
   
   'Update HIV in the record to N/A since not tested
   CnUser.Open ConnectString
   Cmd.CommandText = "UPDATE client SET " & _
                     "HIV = '98' " & _
                     "WHERE VISITID = " & VISITID
   Cmd.CommandType = adCmdText
   Cmd.ActiveConnection = CnUser
   Cmd.Execute
   CnUser.Close
   
   VISITTYP = "2"
   UpdateRecord
   'Print the form now since they will not go any further
'   PrintTestForm.Show

   'init the variables and go straight to risk reduction counseling
   DISCOR = ""
   RRPLAN0 = "1" 'I changed this
   RRPLAN1 = "0"
   RRPLAN2 = "0"
   RRPLAN3 = "0"
   RRPLAN4 = "0"
   RRPLAN5 = "0"
   RRPLAN6 = "0"
   RRPLAN7 = "0"
   RRPLAN8 = "0"
   RRPLAN9 = "0"
   RRPLAN10 = "0"
   RRPLAN11 = "0"
   RRPLAN12 = "0"
   RRPLAN99 = "0"
   REFTO0 = "1" 'I changed this
   REFTO1 = "0"
   REFTO2 = "0"
   REFTO3 = "0"
   REFTO4 = "0"
   REFTO5 = "0"
   REFTO6 = "0"
   REFTO7 = "0"
   REFTO8 = "0"
   REFTO9 = "0"
   REFTO10 = "0"
   REFTO11 = "0"
   REFTO98 = "0"
   REFTO99 = "0"
   COUNSELD = ""
   GAVETEST = ""
   GAVERESU = ""
   COUNCOND = -1
   
   HIV = "98" 'May be we should write this to the database
 
   If SESSTYPE = "02" Then
      CoupDiscordForm.Show
   Else
      DISCOR = "98"
      RiskReductForm.Show
   End If
   Unload Me
End Sub

Private Sub Form_Load()
   If ORGANIZATION = "MACRO" Then
      FullVCT_Button.Enabled = False
      Counseling_Button.Enabled = False
      SEXHX.UpdateData
      SEXHX.SetStar (12)
      LB.AddItem "Not referred"
      LB.AddItem "Yes, for STI"
      LB.AddItem "Yes, for TB"
      LB.AddItem "Yes, for other"
   Else
      If ORGANIZATION = "LIGHTHOUSE" Then
         LB.Visible = False
         REFERRED = "0"
         FullVCT_Button.Enabled = True
         Counseling_Button.Enabled = True
         SEXHX.UpdateData
      End If
   End If
End Sub

Private Sub FullVCT_Button_Click()
   VISITTYP = "1"
   UpdateRecord
   If ORGANIZATION = "MACRO" Then
      VCTStageForm.Show
   Else
      If ORGANIZATION = "LIGHTHOUSE" Then
         Test1Form.Show
      End If
   End If
   Unload Me
End Sub

Private Sub LB_click()
   Select Case LB.ListIndex
      Case 0
         REFERRED = "0"
      Case 1
         REFERRED = "1"
      Case 2
         REFERRED = "2"
      Case 3
         REFERRED = "3"
   End Select
   SEXHX.UpdateData
   FullVCT_Button.Enabled = True
   Counseling_Button.Enabled = True
End Sub

Private Sub UpdateRecord()
   'make some adjustments for field size and data type before writing to the database
   While Len(LIFEPART) < 3
      LIFEPART = "0" & LIFEPART
   Wend
   
   'Save the sexual history information in the database
   CnUser.Open ConnectString
   Cmd.CommandText = "UPDATE client SET " & _
                     "PRTESTED = '" & PRTESTED & "', " & _
                     "TMONTH = '" & TMONTH & "', " & _
                     "TYEAR = '" & TYEAR & "', " & _
                     "PRTESITE = '" & PRTESITE & "', " & _
                     "EVERHAD = '" & EVERHAD & "', " & _
                     "LIFEPART = '" & LIFEPART & "', " & _
                     "SMONTH = '" & SMONTH & "', " & _
                     "SYEAR = '" & SYEAR & "', " & _
                     "EVERAPED = '" & EVERAPED & "', " & _
                     "PREG = '" & PREG & "', " & _
                     "TRANSFUS = '" & TRANSFUS & "', " & _
                     "STISYMPT = '" & STISYMPT & "', " & _
                     "TBSYMPT = '" & TBSYMPT & "', " & _
                     "REFERRED = '" & REFERRED & "', " & _
                     "TIMEPRE = '" & Format(Now(), "hh:mm:ss") & "', " & _
                     "VISITTYP = '" & VISITTYP & "' " & _
                     "WHERE VISITID = " & VISITID
   Cmd.CommandType = adCmdText
   Cmd.ActiveConnection = CnUser
   Cmd.Execute
   CnUser.Close
   
   'Save the details for the four most recent sexual partners in the last 6 months
   CnUser.Open ConnectString
   Cmd.CommandText = "UPDATE client SET " & _
                     "P1TYPE = '" & PTYPE(0) & "', " & "P1NEW = '" & PNEW(0) & "', " & _
                     "P1STATUS = '" & PSTATUS(0) & "', " & "P1LTSTMO = '" & PLTSTMO(0) & "', " & _
                     "P1LTSTYR = '" & PLTSTYR(0) & "', " & "P1FPMETH = '" & PFPMETH(0) & "', " & _
                     "P1CONUSE = '" & PCONUSE(0) & "', " & "P1CONLST = '" & PCONLST(0) & "', " & _
                     "P2TYPE = '" & PTYPE(1) & "', " & "P2NEW = '" & PNEW(1) & "', " & _
                     "P2STATUS = '" & PSTATUS(1) & "', " & "P2LTSTMO = '" & PLTSTMO(1) & "', " & _
                     "P2LTSTYR = '" & PLTSTYR(1) & "', " & "P2FPMETH = '" & PFPMETH(1) & "', " & _
                     "P2CONUSE = '" & PCONUSE(1) & "', " & "P2CONLST = '" & PCONLST(1) & "', " & _
                     "P3TYPE = '" & PTYPE(2) & "', " & "P3NEW = '" & PNEW(2) & "', " & _
                     "P3STATUS = '" & PSTATUS(2) & "', " & "P3LTSTMO = '" & PLTSTMO(2) & "', " & _
                     "P3LTSTYR = '" & PLTSTYR(2) & "', " & "P3FPMETH = '" & PFPMETH(2) & "', " & _
                     "P3CONUSE = '" & PCONUSE(2) & "', " & "P3CONLST = '" & PCONLST(2) & "', " & _
                     "P4TYPE = '" & PTYPE(3) & "', " & "P4NEW = '" & PNEW(3) & "', " & _
                     "P4STATUS = '" & PSTATUS(3) & "', " & "P4LTSTMO = '" & PLTSTMO(3) & "', " & _
                     "P4LTSTYR = '" & PLTSTYR(3) & "', " & "P4FPMETH = '" & PFPMETH(3) & "', " & _
                     "P4CONUSE = '" & PCONUSE(3) & "', " & "P4CONLST = '" & PCONLST(3) & "' " & _
                     "WHERE VISITID = " & VISITID
   Cmd.CommandType = adCmdText
   Cmd.ActiveConnection = CnUser
   Cmd.Execute
   CnUser.Close
   
End Sub
